﻿using System;
using Avalonia.Controls;

namespace LiveHub.AvaloniaApp.ViewModels.Pages;

public class PageModelBase : ViewModelBase
{
    public Control GetPage()
    {
        var page = GetType().FullName!.Replace(".ViewModels", "").Replace("Model", "");
        var type = Type.GetType(page);
        if (type == null) return new TextBlock { Text = "Not Found: " + page };
        var c = (Control)Activator.CreateInstance(type)!;
        c.DataContext = this;
        return c;
    }
}